package com.gmail.hy87cn.hellohi.server;

import java.util.Date;

import com.gmail.hy87cn.hellohi.shared.HiUser;

/**
 * @author HeYi
 * 
 */
public class HiUserPackage {
	private HiUser user;
	private HiRoomPackage roomPackage;
	private Date lastPulse = new Date();
	private static final int MAX_PULSE = 10000; // ms

	public HiUserPackage(int id) {
		user = new HiUser();
		user.setId(id);
	}

	public HiUser getUser() {
		return user;
	}

	public void setRoomPackage(HiRoomPackage room) {
		this.roomPackage = room;
	}

	public HiRoomPackage getRoomPackage() {
		return roomPackage;
	}

	public void setAlive() {
		lastPulse = new Date();
	}

	public boolean isAlive() {
		Date now = new Date();
		return (now.getTime() - lastPulse.getTime()) < MAX_PULSE;
	}
}
